#include <iostream>

using namespace std;
/*
14-5 In Combined.cpp, create a class D that inherits from B and has a member object of class C. Add code to show when the constructors and destructors are being called.
*/

class A {
	int i;
public:
	A(int ii) : i(ii) {
		cout << "the constructor of class A is called." << endl;

	}
	~A() {
		cout << "the destructor of class A is called." << endl;
	}
	void f() const {}
};

class B {
	int i;
public:
	B(int ii) : i(ii) {
		cout << "the constructor of class B is called." << endl;

	}
	~B() {
		cout << "the destructor of class B is called." << endl;
	}
	void f() const {}
};

class C : public B {
	A a;
public:
	C(int ii) : B(ii), a(ii) {
		cout << "the constructor of class C is called." << endl;

	}
	~C() {
		cout << "the destructor of class C is called." << endl;
	} // Calls ~A() and ~B()
	void f() const {  // Redefinition
		a.f();
		B::f();
	}
};

class D:public B {
	C c;
public:
	D(int ii):B(ii),c(ii){
		cout << "the constructor of class D is called." << endl;
	}
	
	~D() {
		cout << "the destructor of class D is called." << endl;
	}
};

int main(int argc, char *argv[]) {
	D d(45);
}